<template>
    <div>
      <h1>User Management</h1>
      <ul>
        <li v-for="user in users" :key="user.id">{{ user.name }} ({{ user.email }})</li>
      </ul>
    </div>
  </template>
  
  <script>
  import axios from 'axios';
  
  export default {
    data() {
      return {
        users: [],
      };
    },
    async created() {
      await this.fetchUsers();
    },
    methods: {
      async fetchUsers() {
        try {
          const response = await axios.get('http://localhost:8080/api/v1/users');
          this.users = response.data;
        } catch (error) {
          console.error('Error fetching users:', error);
        }
      },
    },
  };
  </script>
  
  <style scoped>
  /* 样式可以根据需要添加 */
  </style>
  